<template>
	<view>
		<u-navbar placeholder fixed autoBack title="工资管理"></u-navbar>
		<view class="search u-border-bottom d-p-l-30 d-p-r-30 d-p-t-20 d-p-b-20 d-flex">
			<view class="input d-flex d-flex-1">
				<u-icon name="search" size="38rpx" color="#ADB4BD"></u-icon>
				<view class="d-flex-1"><u--input v-model="keyWord" border="none" style="padding: 0;height: 75rpx;" placeholder="请输入项目名称查询信息"></u--input></view>
			</view>
			<u-button text="搜索" type="primary" @click="search" :customStyle="{ width: '136rpx', height: '75rpx', marginLeft: '20rpx' }"></u-button>
		</view>
		<u-gap height="115rpx" bgColor="#ffffff"></u-gap>
		<view class="d-p-30">
			<template v-if="list && list.length > 0">
				<view class="card d-p-30 d-m-b-30" v-for="(item, index) in list" :key="index" @click="wagesDetail(item)">
					<view class="d-flex">
						<view class="d-font-28 d-flex-1" style="color: #151C24;font-weight: bold;">{{ item.gcmc }}</view>
					</view>
					<view class="d-flex d-m-t-20 d-font-24" style="color: #5D6672;">
						<view class="d-flex-1">
							<text>属地类型</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.districtName }}</text>
						</view>
						<view class="d-flex-1">
							<text>工资发放月(最近)</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.ffgzny }}</text>
						</view>
					</view>
					<view class="d-flex d-m-t-20 d-font-24" style="color: #5D6672;">
						<view class="d-flex-1">
							<!-- todo 无 -->
							<text>最近发放人数</text>
							<text class="d-m-l-20" style="color: #162233;">121</text>
						</view>
						<view class="d-flex-1">
							<!-- todo 无 -->
							<text>最近发放金额</text>
							<text class="d-m-l-20" style="color: #162233;">60000万元</text>
						</view>
					</view>
					<view class="d-flex d-m-t-20 d-font-24" style="color: #5D6672;">
						<view class="d-flex-1">
							<text>累积发放次数</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.cumtimes }}</text>
						</view>
						<view class="d-flex-1">
							<text>累积发放人数</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.cumstaffs }}</text>
						</view>
					</view>
					<view class="d-flex d-m-t-20 d-font-24" style="color: #5D6672;">
						<view class="d-flex-1">
							<!-- todo 无 -->
							<text>累积发放金额</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.cumsalary }}</text>
						</view>
					</view>
				</view>
			</template>
			<template v-else>
				<view style="padding-top: 10vh;"><u-empty icon="/static/image/none.png" :text="show ? '未搜索到相关数据' : '请输入关键词进行查询'"></u-empty></view>
			</template>
		</view>
	</view>
</template>

<script>
import { salaryProject } from '../../../common/api.js';
export default {
	data() {
		return {
			pageNum: 1,
			pageSize: 1,
			pageLast: 1,
			list: [],
			keyWord: '',
			show: false
		};
	},
	onReachBottom() {
		if (this.pageLast > this.pageNum) {
			++this.pageNum;
			this.getList().then(e => {
				this.list = this.list.concat(e.data);
			});
		}
	},
	methods: {
		search() {
			if (!this.keyWord) {
				return uni.$u.toast('请输入关键词进行搜索');
			}
			this.getData();
		},
		getData() {
			this.pageNum = 1;
			this.getList().then(e => {
				this.list = e.data;
				this.show = true;
				this.pageLast = Math.ceil(e.total / this.pageSize);
			});
		},
		getList() {
			return salaryProject({
				params: {
					deptId: this.$user.deptId,
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					keyWord: this.keyWord
				}
			});
		},
		wagesDetail(item) {
			uni.$u.route({
				url: '/pages/index/wages/wagesDetail',
				params: {
					id: item.id
				}
			});
		},
	}
};
</script>

<style lang="scss">
.search {
	position: fixed;
	left: 0;
	right: 0;
	z-index: 999;
	background-color: #ffffff;
	.input {
		height: 75rpx;
		background: #f6f7f8;
		border-radius: 10rpx;
		padding: 0 20rpx;
	}
}
.card {
	box-shadow: 0rpx 5rpx 10rpx rgba(0, 0, 0, 0.05);
	border-radius: 10rpx;
	background-color: #ffffff;
}
page {
	background-color: #fbfcfc;
}
</style>
